package com.huang.controller;

import com.huang.entity.Product;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;
@Slf4j
@RestController
public class ProductController {
    @Value("${server.port}")
    private int port;

    @GetMapping("/product/find")
    public Map<String,Object> find(@RequestParam("id") String id){
        HashMap<String, Object> map = new HashMap<>();
         log.info("进入商品服务:[{}]",id);
         map.put("status",true);
         map.put("msg","当前商品服务调用成功,查询商品Id为"+id+",当前服务端口号:"+port);
        return map;
    }
    @GetMapping("/product/test")
    public String testF(){
        return "成功";
    }


    @PostMapping("/product/add")
    public Map<String,Object> add(@RequestBody Product product){
        HashMap<String, Object> map = new HashMap<>();
        log.info("进入商品服务:[{}]",product);
        map.put("msg","当前商品服务调用成功,添加商品,当前服务端口号:"+port);
        map.put("product",product);
        return map;
    }

}
